
public class algs01 {

		public static int searchN(int x){
		int N = 10;
		while(N < x)
			N = N * 10;
		N = N / 10;
		return N;
	}
	public static int searchT(int x){
		int T = 0;
		for(int N = 1; N < x; N=N*10){
			T++;
		}
		return T;
	}
	public static void main(String[] args) {
		int x = 123456789;
		int y = 987654321;
		int a,b;
		
		int t;//counter
		int max;
		int Sum = 0;
		if(x > y)
			max = x;
		else
			max = y;
		t = searchT(max);
		while(t > 0){
		a = searchN(x);
		b = searchN(y);
		Sum = Sum + (x/a)*a + (y/b)*b;
		x = x - (x / a)*a;
		y = y - (y / b)*b;
		t--;
		/*System.out.println(x / 1000);
		a = x / a;
		b = y / b;
		System.out.println(a+b);*/
		
		
		}
		System.out.println(Sum);
	}

}
